package com.example.cv.mapper;

import com.example.cv.model.Admin;
import com.example.cv.model.Employer;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 周杰
 */
@Mapper
public interface AdminMapper {

    /**
     * description:管理员查询
     * @param admin
     * @return com.example.cv.model.Admin
     */
    @Select("SELECT * FROM tb_admin WHERE account=#{account} and password=#{password}")
    Admin findAdmin(Admin admin);

    @Delete("delete from tb_candidate where c_id=#{c_id}")
    boolean deleteCandidateByCId(int c_id);

    @Delete("delete from tb_employer where e_id=#{e_id}")
    boolean deleteEmployerByEId(int e_id);

    @Update("update tb_admin set account=#{account},password=#{password} where a_id=#{a_id}")
    boolean updateAdmin(Admin admin);

    @Select("select * from tb_admin where a_id=#{a_id}")
    Admin findAdminById(int a_id);

    @Select("select * from tb_employer where name=#{e_name}")
    List<Employer> findEmployersByEName(String e_name);

    @Select("select * from tb_employer")
    List<Employer> findAllEmployers();
}
